home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7600 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Do you have ever pass structures?
  5. Date: 25 Feb 1996 16:39:34 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4gqvg6INNfnf@keats.ugrad.cs.ubc.ca>
  8. References: <4ge8mi$qjm@srvr1.engin.umich.edu> <4ggsio$343@news-f.iadfw.net> <4gqk11$e7l@airdmhor.gen.nz>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4gqk11$e7l@airdmhor.gen.nz>,
  12. Simon Hosie <gumboot@airdmhor.gen.nz> wrote:
  13. >Adam Peterson:
  14. >> The *disadvantage* is speed and space. Passing a pointer is just
  15. >> word//double word.  Passing the actual structure requires loading the
  16. >> stack with all the elements of the structure...slow...
  17. >
  18. >  But once it's done you don't have this pointer-thing to dereference all
  19. >the time (of course, this depends on how much register space you have - will
  20. >I ever get over my Intelesque hangups?).
  21.  
  22. Yes you will have this "pointer thing to dereference". Because the argument
  23. will most likely be on your stack. And what is the stack if not another
  24. pointer?
  25.  
  26. The elimination of apparent indirection of reference is not the motivation for
  27. passing structures by value. What it buys you is, in the case that you need to
  28. make a local copy of a structure, a way to do it invisibly in a syntactically
  29. succint manner. Same with passing structures as return values.
  30. -- 
  31.  
  32.